package com.example.rental.service.impl;

import com.example.rental.entity.Houseinfo;
import com.example.rental.entity.Power;
import com.example.rental.entity.dto.PowerDto;
import com.example.rental.mapper.PowerMapper;
import com.example.rental.result.Result;
import com.example.rental.service.PowerService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
@Data
public class PowerServiceImpl implements PowerService {
    @Autowired
    private PowerMapper powerMapper;

    @Override
    public Result searchPower(PowerDto powerDto) {
        PageHelper.startPage(powerDto.getPage(), powerDto.getLimit());

        List<Power> list = powerMapper.searchPower(powerDto);

        Page page = (Page) list;
        Result<Page> result = Result.ok(page);
        result.setCount(page.getTotal());
        return result;
    }
    @Override
    public void addPower(Power power){powerMapper.addPower(power);};
    @Override
    public void updatePower(Power power){powerMapper.updatePower(power);};
}
